clear all
version 15
cd "_____"
set more off

import delimited "./final_data.csv", clear 

gen date2=date(date,"MD20Y")
format date2 %td
gen year=year(date2)
gen doy=doy(date2)
gen woy=week(date2)   // week of year will be used latter for block booststrap
egen id = group(city)
drop if pm<0  
drop if pm==.
replace pm=floor(pm*1000)/1000
rename pm pmconc

keep pmconc id city doy woy year 
gen dummypollday=(pmconc>float(0.15))
by id year, sort: gen totday= _N
//drop if totday<100
by id year, sort: egen pollday=sum(dummypollday)
by id, sort: egen t0=min(year)
by id, sort: gen temp=pollday if year==t0
by id, sort: egen pollday0=mean(temp)
drop temp
by id, sort: gen temp=totday if year==t0
by id, sort: egen totday0=mean(temp)
drop temp
save "./data/pm10data.dta", replace  
